<template>
  <!-- 库存管理 -->
  <el-container>
    <el-header>
      <div class="left-panel">
        <!-- <el-button type="primary" icon="el-icon-plus" @click="add"></el-button> -->
      </div>
      <div class="right-panel">
        <div class="right-panel-search">
          <el-input
            v-model="searchValue.search"
            placeholder="仓库名称/物品名称"
            clearable
          ></el-input>
          <el-button
            type="primary"
            icon="el-icon-search"
            @click="upsearch"
          ></el-button>
        </div>
      </div>
    </el-header>
    <el-main class="nopadding">
      <scTable ref="table" :apiObj="apiObj" row-key="id" stripe>
        <el-table-column label="ID" prop="id" width="50"></el-table-column>
        <el-table-column label="物品名称" prop="productName"></el-table-column>
        <el-table-column
          label="分类"
          prop="categoryName"
          width="250"
        ></el-table-column>
        <el-table-column
          label="物品规格"
          prop="specificationName"
          width="250"
        ></el-table-column>
        <el-table-column
          label="仓库名称"
          prop="warehouseName"
        ></el-table-column>
        <el-table-column
          label="单位"
          prop="unitName"
          width="200"
        ></el-table-column>
        <el-table-column
          label="库存"
          prop="quantity"
          width="200"
        ></el-table-column>
        <!-- <el-table-column label="操作" fixed="right" align="center" width="250">
          <template #default="scope">
            <el-button-group>
               <el-button
                text
                type="primary"
                size="small"
                @click="table_show(scope.row, scope.$index)"
                v-auth-button="['show/vendor']"
                >查看</el-button
              > 
              <el-button
                text
                type="primary"
                size="small"
                @click="table_edit(scope.row, scope.$index)"
                >编辑</el-button
              >
          <el-popconfirm
                title="确定删除吗？"
                @confirm="table_del(scope.row, scope.$index)"
              >
                <template #reference>
                  <el-button
                    text
                    type="primary"
                    size="small"
                    v-auth-button="['delete/vendor']"
                    >删除</el-button
                  >
                </template>
              </el-popconfirm>
            </el-button-group>
          </template>
        </el-table-column> -->
      </scTable>
    </el-main>
  </el-container>
</template>

<script>

export default {
  name: 'stock',
  data () {
    return {
      dialog: {
        save: false,
      },
      apiObj: this.$API.inventory.getStockList,
      searchValue: {
        search: null
      }
    }
  },
  methods: {
    //添加
    add () {
      this.dialog.save = true
      this.$nextTick(() => {
        this.$refs.saveDialog.open()
      })
      // this.$router.push({
      //   path: '/customer/vendor/addProduct'
      // })
    },

    //编辑
    table_edit (row) {
      this.dialog.save = true
      this.$nextTick(() => {
        this.$refs.saveDialog.open('edit').setData(row)
      })
    },

    //查看
    table_show (row) {
      this.dialog.save = true
      this.$nextTick(() => {
        this.$refs.saveDialog.open('show').setData(row)
      })
    },

    //搜索
    upsearch () {
      this.$refs.table.upData(this.searchValue)
    },

    //本地更新数据
    handleSaveSuccess (data, mode) {
      if (mode == 'add') {
        // this.$refs.table.refresh()
      } else if (mode == 'edit') {
        // this.$refs.table.refresh()
      }
      this.$refs.table.refresh()
    },

  }
}
</script>

<style>
</style>